const H5 = () => {

  var ua = window.navigator.userAgent.toLowerCase()
  return ua.match(/micromessenger/i) == 'micromessenger' ? true : false
}
export const ALIPAY_PAY = (orderInfo) => {
  return new Promise((resolve, reject) => {
    uni.requestPayment({
      provider: 'alipay',
      orderInfo, //微信、支付宝订单数据 【注意微信的订单信息，键值应该全部是小写，不能采用驼峰命名】
      success: function (res) {
        resolve(res)
        console.log('success:' + JSON.stringify(res))
      },
      fail: function (err) {
        console.log('fail:' + JSON.stringify(err))
        uni.showModal({
          title: '错误提示',
          content: err.message,
          showCancel: false,
        })
      }
    })
  })

}
export const WEIXIN_PAY = (orderInfo) => {
  return new Promise((resolve, reject) => {
    uni.requestPayment({
      provider: 'wxpay',
      orderInfo,
      success (res) {
        resolve(res)
      },
      fail (err) {
        reject(err)
        uni.showModal({
          title: '错误提示',
          content: err.message,
          showCancel: false,
        })
      }
    })
  })

}
export const MP_WEIXIN_PAY = (orderInfo) => {
  uni.requestPayment({
    provider: 'wxpay',
    timeStamp: String(Date.now()),
    nonceStr: orderInfo.nonceStr,
    package: orderInfo.package,
    signType: 'MD5',
    paySign: '',
    success: function (res) {
      console.log('success:' + JSON.stringify(res))
    },
    fail: function (err) {
      console.log('fail:' + JSON.stringify(err))
    }
  })
}
